package component.auxiliares.view;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import component.auxiliares.Slider;


/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class SliderConfig extends javax.swing.JFrame {
	private JLabel lblVariable;
	private JComboBox cmbVariable;
	private JTextField txtRef;
	private JTextField txtMax;
	private JButton btnCancel;
	private JButton btnOK;
	private JSeparator jSeparator1;
	private JTextField txtMin;
	private JLabel lblMax;
	private JLabel lblRef;
	private JLabel lblMin;
	private Slider main;

	/**
	 * Auto-generated main method to display this JFrame
	 */
	// public static void main(String[] args) {
	// SwingUtilities.invokeLater(new Runnable() {
	// public void run() {
	// SliderConfig inst = new SliderConfig();
	// inst.setLocationRelativeTo(null);
	// inst.setVisible(true);
	// }
	// });
	// }
	public SliderConfig(Slider slider) {
		super();
		this.main = slider;
		initGUI();
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("i2M - Slider");
			{
				lblVariable = new JLabel();
				getContentPane().add(lblVariable);
				lblVariable.setText("Variável:");
				lblVariable.setBounds(12, 12, 61, 14);
			}
			{
				ComboBoxModel cmbVariableModel = new DefaultComboBoxModel(
						new String[] { "Item One", "Item Two" });
				cmbVariable = new JComboBox();
				getContentPane().add(cmbVariable);
				cmbVariable.setModel(cmbVariableModel);
				cmbVariable.setBounds(73, 9, 196, 21);
			}
			{
				lblMin = new JLabel();
				getContentPane().add(lblMin);
				lblMin.setText("Mínimo:");
				lblMin.setBounds(12, 38, 68, 14);
			}
			{
				lblRef = new JLabel();
				getContentPane().add(lblRef);
				lblRef.setText("Referência: ");
				lblRef.setBounds(12, 65, 75, 14);
			}
			{
				lblMax = new JLabel();
				getContentPane().add(lblMax);
				lblMax.setText("Máximo: ");
				lblMax.setBounds(154, 38, 55, 14);
			}
			{
				txtMin = new JTextField();
				getContentPane().add(txtMin);
				txtMin.setBounds(88, 35, 54, 21);
			}
			{
				txtRef = new JTextField();
				getContentPane().add(txtRef);
				txtRef.setBounds(88, 62, 54, 21);
			}
			{
				txtMax = new JTextField();
				getContentPane().add(txtMax);
				txtMax.setBounds(215, 35, 54, 21);
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(12, 95, 257, 10);
			}
			{
				btnOK = new JButton();
				getContentPane().add(btnOK);
				btnOK.setText("OK");
				btnOK.setBounds(12, 105, 111, 21);
				btnOK.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						btnOkMouseClicked(evt);
					}
				});
			}
			{
				btnCancel = new JButton();
				getContentPane().add(btnCancel);
				btnCancel.setText("Cancelar");
				btnCancel.setBounds(154, 105, 117, 21);
				btnCancel.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						btnCancelMouseClicked(evt);
					}
				});
			}
			pack();
			this.setSize(289, 172);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public JComboBox getCmbVariable() {
		return cmbVariable;
	}

	public JTextField getTxtRef() {
		return txtRef;
	}

	public JTextField getTxtMax() {
		return txtMax;
	}

	public JTextField getTxtMin() {
		return txtMin;
	}

	private void btnCancelMouseClicked(MouseEvent evt) {
		this.dispose();
	}

	private void btnOkMouseClicked(MouseEvent evt) {
		main.atualiza(this);
	}
}
